import React from "react";
import { Tree } from 'antd';
const TreeNode = Tree.TreeNode;

class TreeDom extends React.Component {

    onSelect = (selectedKeys, info) => {

        this.props.onAdd(selectedKeys,info)

    }

    render() {
        return (
            <Tree

                onSelect={this.onSelect}
                onCheck={this.onCheck}
            >
                {
                    this.props.getData.map((res)=>{

                       if(res.children&&res.children.length){

                           return       <TreeNode parentId={res.parentId} title={res.name} key={res.id} level={res.level}>
                                       {
                                           res.children.map(menu=>(
                                               <TreeNode parentId={menu.parentId} level={menu.level} title={ menu.name} key={menu.id}></TreeNode>
                                           ))
                                       }
                                    </TreeNode>
                       }
                       else{
                           return <TreeNode parentId={res.parentId} level={res.level} title={res.name} key={res.id}></TreeNode>
                       }
                    })
                }

            </Tree>
        );
    }
}
export  default TreeDom;
